package com.ruoyi.web.controller.video;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.video.domain.VImage;
import com.ruoyi.video.service.IVImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图片存储Controller
 * 
 * @author orange
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/video/image")
public class VImageController extends BaseController
{
    @Autowired
    private IVImageService vImageService;

    /**
     * 查询图片存储列表
     */
    @PreAuthorize("@ss.hasPermi('video:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(VImage vImage)
    {
        startPage();
        List<VImage> list = vImageService.selectVImageList(vImage);
        return getDataTable(list);
    }

    /**
     * 导出图片存储列表
     */
    @PreAuthorize("@ss.hasPermi('video:image:export')")
    @Log(title = "图片存储", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VImage vImage)
    {
        List<VImage> list = vImageService.selectVImageList(vImage);
        ExcelUtil<VImage> util = new ExcelUtil<VImage>(VImage.class);
        util.exportExcel(response, list, "图片存储数据");
    }

    /**
     * 获取图片存储详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:image:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vImageService.selectVImageById(id));
    }

    /**
     * 新增图片存储
     */
    @PreAuthorize("@ss.hasPermi('video:image:add')")
    @Log(title = "图片存储", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VImage vImage)
    {
        return toAjax(vImageService.insertVImage(vImage));
    }

    /**
     * 修改图片存储
     */
    @PreAuthorize("@ss.hasPermi('video:image:edit')")
    @Log(title = "图片存储", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VImage vImage)
    {
        return toAjax(vImageService.updateVImage(vImage));
    }

    /**
     * 删除图片存储
     */
    @PreAuthorize("@ss.hasPermi('video:image:remove')")
    @Log(title = "图片存储", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vImageService.deleteVImageByIds(ids));
    }
}
